package com.sms.controller;

import cn.hutool.json.JSONUtil;
import com.sms.common.A;
import com.sms.service.impl.ProductsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//商品删除
@WebServlet("/ProductsRemove")
public class ProductsRemoveController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        Integer productID=Integer.parseInt(request.getParameter("productID"));

        ProductsServiceImpl impl=new ProductsServiceImpl();
        impl.removeById(productID);
        impl.getSqlSession().close();
        A r= A.success("删除成功");
        response.getWriter().write(JSONUtil.toJsonStr(r));
    }
}
